﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace BTN04.DTO
{
    public class Mail
    {
        private System.Net.Mail.MailMessage _mail = new System.Net.Mail.MailMessage();
        public Mail(string fromName, string fromMail, string toName, string toMail, string subject, string body, bool isHtml)
        {
            this._mail.Subject = subject;
            this._mail.Body = body;
            this._mail.From = new System.Net.Mail.MailAddress(fromMail, fromName);
            this._mail.To.Add(new System.Net.Mail.MailAddress(toMail, toName));
            this._mail.IsBodyHtml = isHtml;
            this._mail.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
            this._mail.SubjectEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
        }
        public bool Send()
        {
            try
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("localhost"); // Mettre le serveur smtp ici
                smtp.Send(this._mail);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
